<?php

namespace app\model;

use think\Model;

class OrderTransactionLog extends Model
{
    protected $createTime = 'create_date';

    public function getSubmitIdAttr($name)
    {
        return [
            'id' => $name,
            'text' => (new User)->getIdNickName($name) ?: ''
        ];
    }

    public function createModel($data)
    {
        return self::create($data);
    }

    public function getIdDataModel($id)
    {
        return $this->where (['tid'=>$id])->select ()->toArray ();
    }
    /**
     * 获取审批通过时间
     */
    public function getExamineDateModel($id)
    {
        return $this->whereRaw ('tid='.$id.' and content= "'.'收款审核通过"'.' OR tid='.$id.' and content = "'.'付款审核通过'.'"')->order ('create_date DESC')->value('create_date');
    }

    /**
     * 获取收款||付款审批时间
     * @param $id
     * @param $text
     * @return mixed
     */
    public function getTypeExamineDateModel($id,$text)
    {
        return $this->where(['tid'=>$id,'content'=>$text])->order ('create_date DESC')->value('create_date');
    }

    public function editIdDataModel($id,$content, array $array)
    {
        return $this->where (['tid'=>$id,'content'=>$content])->update ($array);
    }

}